package com.zeng.jiudian.servlet.front;

import com.alibaba.fastjson.JSONObject;
import com.zeng.jiudian.bean.NavModel;
import com.zeng.jiudian.service.NavService;
import com.zeng.jiudian.service.impl.NavServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author JJ_yo
 * @Date 2020/8/10 - 9:43
 */
@WebServlet("/top")
public class TopServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        resp.setContentType("application/json;charset=utf-8");

        NavService navService = new NavServiceImpl();
        List<NavModel> list = navService.getAll();

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", list);
        resp.getWriter().println(jsonObject);
    }
}
